package main

import (
	"fmt"
)

type Flags uint

const (
	FlagUp Flags = 1 << iota // is up
	FlagBroadcast
	FlagLoopback
	FlagPointToPoint
	FlagMulticast
)

func IsUp(v Flags) bool {
	return v&FlagUp == FlagUp;
}

func TurnDown(v *Flags) {
	*v &^= FlagUp;
}

func SetBroadcast(v *Flags) {
	*v |= FlagBroadcast;
}

func IsCast(v Flags) bool {
	return v&(FlagBroadcast|FlagMulticast) != 0;
}

func output(v Flags) {
	fmt.Printf("%b %t\n", v, IsUp(v));
}

func main() {
	var v Flags = FlagMulticast | FlagUp;
	output(v);
	TurnDown(&v);
	output(v);
	SetBroadcast(&v);
	output(v);
	fmt.Printf("%b %t\n", v, IsCast(v));

	//
	deadbeef := 0xdeadbeef;
	a := uint(deadbeef);
	fmt.Println(a);
	var b int = 0x30041278;
	fmt.Println(b);
	var c int = 1e7;
	fmt.Println(c);
}

//P115
